/**
 * 漆水河 脚手架基础公开课
 * 2022/8/13 --- 2022/12/13
 * 有疑问可加QQ群: 809126489，后续会持续输出与大家一起成长
 */
package com.qishuihe.basedomain.infrastructure.aspect.logicdelete;

import com.baomidou.mybatisplus.extension.service.IService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
@Aspect
@Slf4j
public class LogicDeleteAspect {

    @Pointcut("execution(* com.baomidou.mybatisplus.extension.service.IService.removeById(..))")
    public void annotationPointCut(){}

    @Around("annotationPointCut()")
    Object  removeById(ProceedingJoinPoint joinPoint ) throws Throwable {
        log.info("1234");
        IService service = (IService)joinPoint.getTarget();
        Object[] id = joinPoint.getArgs();
        List<Long> ids = new ArrayList<>();
        ids.add((Long)id[0]);
        return  service.removeByIds(ids);
    }

}
